class Solution {
  public int[] singleNumbers(int[] nums) {
    int res = 0;
    for (int num : nums) {
      res ^= num;
    }
    int index = 1;
    while ((index & res) == 0) {
      index <<= 1;
    }
    int[] arr = { 0, 0 };
    for (int num : nums) {
      if ((index & num) == 0) {
        arr[0] ^= num;
      } else {
        arr[1] ^= num;
      }
    }
    return arr;
  }

  public static void main(String[] args) {
    new Solution().singleNumbers(new int[] { 1, 2, 5, 2 });
  }
}